<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.hs.pre.model.PreEntry" %>
<%@ page import="com.hs.pre.page.PageUtil" %>
<%@ page import="com.hs.utils.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List list = new ArrayList(); 
PageUtil pageUtil = (PageUtil)request.getAttribute("pageUtil");
System.out.println("===========pageUtil:"+pageUtil);
    list = pageUtil.getResultList();
%>

<html>
  <head>
    <base href="<%=basePath%>"> 
    <META content="MSHTML 6.00.2900.3268" name=GENERATOR> 
        <LINK href="<%=basePath%>/app/css/default.css" type=text/css rel=stylesheet>
     <SCRIPT src="<%=path %>/app/js/common.js" type=text/javascript></SCRIPT> 
     <script type="text/javascript">
     function editPre(){
         var preId = '';
         var count = 0;
         var flag = true;
         var rows = document.getElementsByName("preId");   
	     if(null != rows){ 
	        for(var i=0;i<rows.length;i++){
	            if(rows[i].checked){   
	               preId = rows[i].value;
	               count+=1;
	            }
	            if(count > 1){
	              alert("请选择一个方剂进行编辑");
	              preId = '';
	              flag = false;
	              break;
	            }
	        } 
	        if(!flag)
	          return;
	     }  
	     if('' == preId){
	        alert("请选择方剂进行编辑");
	        return;
	     }
         openwindow('<%=path%>/admin/manage.do?action=edit&preId='+preId,'1100','800','');
     
     }
     function newPre(){ 
       openwindow('<%=path%>/admin/manage.do?action=edit','1100','800','');
     }
     function viewPre(preId){
       openwindow('<%=path%>/app/admin/viewPre.jsp?preId='+preId,'1100','800',''); 
     }
     </script>
    </HEAD>
<BODY>
<table cellSpacing=0 align=right cellPadding=0 border=0>
<tr>
<td>
<table   cellSpacing=0 align=right cellPadding=0 border=0 valign=top>
<tr>
<td><input name="button" type="button" class="buttom"  onclick="newPre();" value="添加方剂"></td>
<td><input name="button" type="button" class="buttom"  onclick="editPre();" value="编辑方剂"></td> 
<td><input name="button" type="button" class="buttom" onclick="window.location='<%=path %>/app/pre/simpleSearch.do?q=q:0&sortIdaa=<%=request.getParameter("sortId") %>'" value="方剂分类"></td>
<td><input name="button" type="button" class="buttom" onclick="form1.submit();" value="移除方剂"></td>
<td></td>
</tr>
</table>
</td>
</tr>
	<tr heigth="5px"><td><br></td></tr>
	<tr>
	<td>
<DIV class=tab>
<form  id="form1" method="post" action="<%=path %>/perInfo.do?perInfo=delSortPreRel&sortId=<%=request.getParameter("sortId") %>" >
<TABLE  style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all; TEXT-ALIGN: justify" width=100% cellSpacing=0 cellPadding=0 border=0>
  <TBODY>
  <TR class=top>
    <TD width=5%><input type="checkbox" value="" id="sel_id" onclick="fullsel(form1,'sel_id','preId')" name=""></TD>
    <TD width=5%>序号</TD>
    <TD width=30%>方名</TD>
    <TD width=20%>来源</TD>
    <TD width=30%>药物组成</TD>
    <TD width=10%>功效</TD>
    <TD width=10%>主治</TD>
    </TR>
	   <%
	  int size = list.size();
	  for(int i=0;i<size;i++){
	    PreEntry preEntry =(PreEntry)list.get(i);
	   %>
	  <TR align=center bgColor=<%if(i%2 == 0){out.println("#fffbff");}else{out.println("#eef1f9");} %>>
	     <TD><input type="checkbox" value="<%=preEntry.getPreId() %>" name="preId"></TD>
	    <TD><FONT color=#ff3300><%=pageUtil.getIPage().getThisNum()+i %></FONT></TD>
	  
	    <TD><a href="javaScript:viewPre('<%=preEntry.getPreId()%>');"><%=preEntry.getFangm() %></a></TD>
	    <TD><%=preEntry.getChufly() %></TD>
	    <TD><%=Utilities.null2Blank(preEntry.getYaowzc()) %></TD>
	    <TD><%=Utilities.null2Blank(preEntry.getGongx()) %></TD>
	    <TD><%=Utilities.null2Blank(preEntry.getZhuz()) %></TD>
	    </TR>
	    <%} %>
	  </TBODY>
	</TABLE>
	</form>
  </DIV>
  </td>
  </tr> 
  <tr>
  	<td><%=pageUtil.viewHTML() %></td>
  </tr> 
</table>
</BODY></HTML>